#include <iostream>
#include <vector>
#include <string>

using namespace std;

// 定义电量状态枚举
enum BatteryStatus {
    LOW, MEDIUM, HIGH, FULL
};

// 定义电池类
class Battery {
private:
    double capacity; // 电池容量
    double currentLevel; // 当前电量
    BatteryStatus status; // 电量状态
    vector<string> chargingHistory; // 充电历史记录

public:
    Battery(double capacity) : capacity(capacity), currentLevel(0), status(LOW) {}

    void charge(double amount) {
        currentLevel += amount;
        if (currentLevel >= capacity) {
            currentLevel = capacity;
            status = FULL;
        } else if (currentLevel > 0.5 * capacity) {
            status = MEDIUM;
        } else {
            status = LOW;
        }
        chargingHistory.push_back("Charged " + to_string(amount) + " units.");
    }

    double getCapacity() const {
        return capacity;
    }

    double getCurrentLevel() const {
        return currentLevel;
    }

    BatteryStatus getStatus() const {
        return status;
    }

    const vector<string>& getChargingHistory() const {
        return chargingHistory;
    }
};

// 定义充电方式抽象基类
class ChargingMethod {
public:
    virtual void charge(Battery& battery) = 0;
    virtual ~ChargingMethod() {}
};

// 定义快速充电类
class FastCharging : public ChargingMethod {
public:
    void charge(Battery& battery) override {
        cout << "Charging with fast charging." << endl;
        battery.charge(battery.getCapacity() * 0.8); // 假设快速充电效率为80%
    }
};

// 定义无线充电类
class WirelessCharging : public ChargingMethod {
public:
    void charge(Battery& battery) override {
        cout << "Charging with wireless charging." << endl;
        battery.charge(battery.getCapacity() * 0.5); // 假设无线充电效率为50%
    }
};

// 主函数
int main() {
    Battery battery(100); // 假设电池容量为100单位
    ChargingMethod* fastCharging = new FastCharging();
    ChargingMethod* wirelessCharging = new WirelessCharging();

    cout << "Initial battery status: " << battery.getStatus() << endl;
    fastCharging->charge(battery);
    cout << "After fast charging: " << battery.getStatus() << endl;
    wirelessCharging->charge(battery);
    cout << "After wireless charging: " << battery.getStatus() << endl;

    cout << "Charging history: ";
    for (const auto& record : battery.getChargingHistory()) {
        cout << record << " ";
    }
    cout << endl;

    // 清理资源
    delete fastCharging;
    delete wirelessCharging;

    return 0;
}
